even_number = list(range(2,101,2))
print("1.1-100的所有偶数:",even_number)
squared_number=[num ** 2 for num in even_number]
print("2.所有偶数替换为他们的平方:",squared_number)
filtered_number=[num for num in squared_number if num <= 1000]
print("3.删除所有大于一千的数字:",filtered_number)
reversed_number=filtered_number[::-1]
print("4.将列表逆转:",reversed_number)
first_10 = reversed_number[:10]
print("5.前十个元素：:",first_10)
current_list = first_10.copy()
current_list.extend([101,102,103])
print("6.添加后:",current_list)
average = sum(current_list)/len(current_list)
print("7.列表中元素的平均值:",average)
max_value = max(current_list)
min_value = min(current_list)
print("8.最大值:",max_value,"最小值：",min_value)
if 11 not in current_list:
    current_list.append(11)
index = current_list.index(11)
print("9.第一次出现11的索引位置:",index)
str_list = [str(num) for num in current_list]
print("10.for循环转换为字符串:",str_list)
float_list = [float(num) for num in current_list]
print("11.转换为浮点数*:",float_list)
count_above_50 = sum(1 for num in current_list if num > 50)
print("12.大于五十的元素个数:",count_above_50)
current_list.insert(2,99)
print("13.在第三个位置插入99后:",current_list)
current_list.pop()
print("14.删除最后一个元素:",current_list)
doubled_list = [num * 2 for num in current_list]
print("15.元素乘二后:",doubled_list)
less_or_equal_50 = [num for num in current_list if num <= 50]
greater_50 = [num for num in current_list if num > 50]
print("16.小于等于50的数:",less_or_equal_50,"大于50的数：",greater_50)
list_dict = {num : index for index, num in enumerate(current_list)}
print("17.转换为字典:",list_dict)
print("18.元素及其索引:")
for index , num in enumerate(current_list):
    print(f" 索引：{index},元素:{num}")
import random
random_element = random.choice(current_list)
print("19. 随机取出的元素:", random_element)
with open("list_elements.txt", "w") as file:
    for num in current_list:
        file.write(f"{num}\n")
print("20. 列表已保存到list_elements.txt文件")